package net.apexes.demo.codegen.dslite.qvar;

import net.apexes.demo.codegen.dslite.entity.ShopTemplate;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QShopTemplate is a DSLite query type for ShopTemplate
 * @see ShopTemplate
 */
public class QShopTemplate extends QEntityBase<ShopTemplate> {

    public static final QShopTemplate $ = new QShopTemplate("SHOP_TEMPLATE");

    public final StringColumn shopId = varchar("SHOP_ID", 22).field("shopId").notNull().build();

    public final StringColumn templateId = varchar("TEMPLATE_ID", 22).field("templateId").notNull().build();

    public class Indexs {

        public final Index constraintIndexAd = index("CONSTRAINT_INDEX_AD").column(shopId).build();

        public final Index constraintIndexAd3 = index("CONSTRAINT_INDEX_AD3").column(templateId).build();

        public final Index primaryKeyAd = index("PRIMARY_KEY_AD").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraintAd3 = foreignKey(shopId, "SHOP", "ID");

        public final ForeignKey constraintAd3e = foreignKey(templateId, "TEMPLATE", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QShopTemplate(String tableName) {
        super(ShopTemplate.class, tableName);
    }

    @Override
    public ShopTemplate newEntity() {
        return new ShopTemplate();
    }

    @Override
    public Object getFieldValue(ShopTemplate entity, String fieldName) {
        switch (fieldName) {
            case "shopId":
                return entity.getShopId();
            case "templateId":
                return entity.getTemplateId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(ShopTemplate entity, String fieldName, Object value) {
        switch (fieldName) {
            case "shopId":
                entity.setShopId((java.lang.String) value);
                break;
            case "templateId":
                entity.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

